const { override, fixBabelImports, addLessLoader, overrideDevServer } = require('customize-cra')
const darkThemeVars = require('antd/dist/dark-theme')
const path = require('path')
function resolve(dir) {
    return path.join(__dirname, '.', dir)
}
const addProxy = () => (configFunction) => {
    configFunction.proxy = {
        // '/edurobot/ws': {
        //     // target: 'ws://172.19.81.37:11910/edurobot/ws',
        //     // target: 'ws://edurobot.ths123.com:10050/edurobot/ws',
        //     ws: true,
        //     secure: false,
        //     logLevel: 'debug',
        //     pathRewrite: { '^/edurobot/ws': '/' },
        //   },
        '/edurobot': {
            target: 'http://172.19.81.37:11900/edurobot',
            // target: 'http://edurobot.ths123.com:10050/edurobot',
            changeOrigin: true,
            pathRewrite: { '^/edurobot': '/' },
        },
        // '/fileServer': {
        //     target: 'http://vopoc.ths123.com/fileServer',
        //     changeOrigin: true,
        //     pathRewrite: { '^/fileServer': '/' },
        // }
    };

    return configFunction;
}
module.exports = {
    webpack: override(
        fixBabelImports("import", {
            libraryName: "antd",
            libraryDirectory: "es",
            style: true
        }),
        addLessLoader({
            javascriptEnabled: true,
            modifyVars: {
                hack: `true;@import "${require.resolve(
                    "antd/lib/style/color/colorPalette.less"
                )}";`,
                // ...darkThemeVars,
                // "@primary-color": "#02b875"
            }
        }),
        (config) => {
            if (process.env.NODE_ENV === 'production') {
                config.output.publicPath = './'
            }
            return config
        }
    ),
    devServer: overrideDevServer(
        addProxy()
    )
};
